Again, joint work with Charlie Peskin (NYU). $\newcommand{\mf}{\mathfrak} \newcommand{\E}{\mathrm{e}} \newcommand{\I}{\mathrm{i}} \newcommand{\mf}{\mathfrak}$
using ApproxFunRational, AbstractIterativeSolvers, Plots
\begin{align*} u(\omega) - \begin{pmatrix} \frac{2 \lambda s_0^2}{\lambda^2 + \omega^2} + p_{\mf n \mf n} + p_{\mf m \mf m} - 1 & \frac{2 \lambda s_0^2}{\lambda^2 + \omega^2} \E^{-\I \Delta_{\mf s} \omega} + p_{\mf n \mf n} \E^{- \I \Delta_{\mf n} \omega} \\ \frac{2 \lambda s_0^2}{\lambda^2 + \omega^2} \E^{\I \Delta_{\mf s} \omega} + p_{\mf n \mf n} \E^{ \I \Delta_{\mf n} \omega} & \frac{2 \lambda s_0^2}{\lambda^2 + \omega^2} + p_{\mf n \mf n} + p_{\mf m \mf m} - 1 \end{pmatrix} \mathcal C^- u(\omega) = \begin{pmatrix} \frac{2 \lambda s_0^2}{\lambda^2 + \omega^2}\E^{ - \I (d - d_{\mf s,1}) \omega} \\ \frac{2 \lambda s_0^2}{\lambda^2 + \omega^2}\E^{ - \I (d - d_{\mf s,2}) \omega} \end{pmatrix} \end{align*}
tol = 1.e-4
Ds1 = 0.5
Ds2 = 1.
Δs = Ds2-Ds1
Dn1 = 1.
Dn2 = 0.5
Δn = Dn2 - Dn1
rn = 1.
s0n = 1/sqrt(2.)
λ = 1.
s0s = 1/sqrt(2.)
pnn = 1
pmm = .2
L = 1.
D = 1.;
fPss = z -> 2*λ*s0s^2.0/(λ^2+z.^2)
#fPss = z -> .1*exp(-z^2/2)
fPnn = z -> pnn
fPmm = z -> pmm
Pss = Fun(zai(fPss),OscLaurent(0.0,L))
One = pad(Fun(1.,OscLaurent(0.0,L)),3)
Pnn = pnn*One
Pmm = pmm*One;
Set up coefficient matrix and right-hand side.
H = zeros(Fun,2,2)
a = Pss + Pnn + Pmm - One
b = Pss*Fun(1.,OscLaurent(-Δs,L)) + Pnn*Fun(1.,OscLaurent(-Δn,L))
bt = Pss*Fun(1.,OscLaurent(Δs,L)) + Pnn*Fun(1.,OscLaurent(Δn,L))
H[1,1] = a
H[2,2] = a
H[1,2] = b
H[2,1] = bt
G = map(SumFun,H)
b1 = Pss*Fun(1.,OscLaurent(- D + Ds1,L))
b2 = Pss*Fun(1.,OscLaurent(- D + Ds2,L))
h = map(SumFun,[b1,b2]);
𝓒⁻ = Cauchy(-1); 𝓕 = FourierTransform(-1.0)
simp(f) = combine!(chop!(f,tol));
𝓢 = x -> simp(x - G*(𝓒⁻*x))
out = GMRES(𝓢,h,⋅,tol,30, x -> x);
û = +([out[2][i]*out[1][i] for i=1:length(out[2])]...);
ω = -20:.01:20
y1 = map(û[1],ω)
plot(ω,real(y1), label = "Real part of u[1]")
plot!(ω,imag(y1), label = "Imaginary part of u[1]")
ω = -20:.01:20
y1 = map(û[2],ω)
plot(ω,real(y1), label = "Real part of u[2]")
plot!(ω,imag(y1), label = "Imaginary part of u[2]")
u = 𝓕*û
ω = 0:.01:15
y1 = map(u[1],ω)
y2 = map(u[2],ω)
plot(ω,real(y1))
plot!(ω,real(y2))